package org.yiqixue.accounts.mapper;

import org.yiqixue.accounts.dto.TransactionDto;
import org.yiqixue.accounts.entity.Transaction;

// Transaction 实体和 DTO 之间的映射类
public class TransactionMapper {

    // 将 Transaction 实体转换为 TransactionDto
    public static TransactionDto mapToTransactionDto(Transaction transaction, TransactionDto transactionDto) {
        transactionDto.setTransactionId(transaction.getTransactionId());
        transactionDto.setAccountNumber(transaction.getAccountNumber());
        transactionDto.setAmount(transaction.getAmount());
        transactionDto.setTransactionDate(transaction.getTransactionDate());
        transactionDto.setDescription(transaction.getDescription());
        transactionDto.setStatus(transaction.getStatus());
        transactionDto.setType(transaction.getType());
        return transactionDto;
    }

    // 将 TransactionDto 转换为 Transaction 实体
    public static Transaction mapToTransaction(TransactionDto transactionDto, Transaction transaction) {
        transaction.setTransactionId(transactionDto.getTransactionId());
        transaction.setAccountNumber(transactionDto.getAccountNumber());
        transaction.setAmount(transactionDto.getAmount());
        transaction.setTransactionDate(transactionDto.getTransactionDate());
        transaction.setDescription(transactionDto.getDescription());
        transaction.setStatus(transactionDto.getStatus());
        transaction.setType(transactionDto.getType());
        return transaction;
    }
}
